<?php
include_once dirname(__FILE__)."/common/basic.php";
if($_GET[fid] && $_GET[fid]!='null'){
	$filepath = $func->buildAvatarPath($_GET[fid]);
	$imagetype = $func->image_type($filepath);
	$content_type = $func->image_type_to_content_type($imagetype);
	if($imagetype==IMG_JPG || $imagetype==IMG_JPEG){
		header("Content-Type: ".$content_type);
		imagejpeg(imagecreatefromjpeg($filepath));
	}else if($imagetype==IMG_PNG){
		header("Content-Type: ".$content_type);
		imagepng(imagecreatefrompng($filepath));
	}else if($imagetype==IMG_GIF){
		header("Content-Type: ".$content_type);
		imagegif(imagecreatefromgif($filepath));
	}else{
		header("Content-Type: image/png");
		imagepng(imagecreatefrompng(dirname(__FILE__).'/resource/avatar_default.png'));
	}
}elseif(isset($_GET['default']) || isset($_GET['l'])){
	header("Content-type: image/png");
	imagepng(imagecreatefrompng(dirname(__FILE__).'/resource/avatar_default.png'));
}elseif(isset($_GET['default_m']) || isset($_GET['m'])){
	header("Content-type: image/png");
	imagepng(imagecreatefrompng(dirname(__FILE__).'/resource/avatar_default_m.png'));
}elseif(isset($_GET['default_s']) || isset($_GET['s'])){
	header("Content-type: image/png");
	imagepng(imagecreatefrompng(dirname(__FILE__).'/resource/avatar_default_s.png'));
}elseif($_GET[pic_fid]){
	$filepath = $func->getFilePathByFID($_GET[pic_fid]);
	if(file_exists($filepath)){
		$imagetype = $func->image_type($filepath);
		$content_type = $func->image_type_to_content_type($imagetype);
		if($imagetype==IMG_JPG || $imagetype==IMG_JPEG){
			header("Content-Type: ".$content_type);
			imagejpeg(imagecreatefromjpeg($filepath));
		}else if($imagetype==IMG_PNG){
			header("Content-Type: ".$content_type);
			imagepng(imagecreatefrompng($filepath));
		}else if($imagetype==IMG_GIF){
			header("Content-Type: ".$content_type);
			imagegif(imagecreatefromgif($filepath));
		}else{
			header("Content-Type: image/png");
			imagepng(imagecreatefrompng(dirname(__FILE__).'/resource/pic_default.png'));
		}
	}else{
		header("Content-Type: image/png");
		imagepng(imagecreatefrompng(dirname(__FILE__).'/resource/pic_default.png'));
	}
}
?>